<script language="javascript" type="text/javascript">
var SELECT_SIZE_JS_MSG = '<?php _e('Please select '); $themeUI->get_product_att1_title($data);?>';
var SELECT_COLOR_JS_MSG = '<?php _e('Please select '); $themeUI->get_product_att2_title($data);?>';
var SELECT_ATT3_JS_MSG = '<?php _e('Please select '); $themeUI->get_product_att3_title($data);?>';
var SELECT_ATT4_JS_MSG = '<?php _e('Please select ').$themeUI->get_product_att4_title($data);?>';
var SELECT_ATT5_JS_MSG = '<?php _e('Please select ').$themeUI->get_product_att5_title($data);?>';
var PRECESSING_MSG = '<?php _e(PRECESSING_MSG);?>';
var siteurl = '<?php echo site_url(); ?>';
var ERROR_LOADING_CART_INFO_JS_MSG= '<?php echo ERROR_LOADING_CART_INFO_JS_MSG;?>';
var ADDED_CART_SUCCESS_MSG = '<?php echo ADDED_CART_SUCCESS_MSG;?>';
var VIEW_CART_DETAIL_TEXT = '<?php echo VIEW_CART_DETAIL_TEXT;?>';
var CHECKOUT_TEXT  = '<?php _e('Checkout Now');?>';
var post_id = '<?php echo $post->ID?>';
var request_url = '<?php echo $_SERVER['REQUEST_URI'];?>';	
var post_id = <?php echo $post->ID?>;
function checkstock(attval)
{
	if(eval('document.getElementById("shoppingcart_button_1")'))
	{
		document.getElementById("shoppingcart_button_1").style.display="";
	}
	if(eval('document.getElementById("shoppingcart_outofstock_msg1")'))
	{
		document.getElementById("shoppingcart_outofstock_msg1").innerHTML="";
	}
	if(eval('document.getElementById("shoppingcart_button_2")'))
	{
		document.getElementById("shoppingcart_button_2").style.display="";
	}
	if(eval('document.getElementById("shoppingcart_outofstock_msg2")'))
	{
		document.getElementById("shoppingcart_outofstock_msg2").innerHTML="";
	}
	<?php
	$product_color_js = $Product->get_product_custom_dl($post->ID,'size','',1);
	echo $product_color_js .= $Product->get_product_custom_dl($post->ID,'color','',1);
	?>
}
function checkstock(attval)
{
	document.getElementById("cat").value = attval;
	if(eval('document.getElementById("shoppingcart_button_1")'))
	{
		document.getElementById("shoppingcart_button_1").style.display="";
	}
	if(eval('document.getElementById("shoppingcart_outofstock_msg1")'))
	{
		document.getElementById("shoppingcart_outofstock_msg1").innerHTML="";
	}
	if(eval('document.getElementById("shoppingcart_button_2")'))
	{
		document.getElementById("shoppingcart_button_2").style.display="";
	}
	if(eval('document.getElementById("shoppingcart_outofstock_msg2")'))
	{
		document.getElementById("shoppingcart_outofstock_msg2").innerHTML="";
	}
	<?php
	$product_color_js = $Product->get_product_custom_dl($post->ID,'size','',1);
	echo $product_color_js .= $Product->get_product_custom_dl($post->ID,'color','',1);
	?>
	chkOrder();
}
</script>
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/library/js/checkout_cart.js"></script>
<input type="hidden" name="cat" id="cat" />
<form id="shopingcartfrm" name="shopingcartfrm" action="">
<div class="row hidden">
  <input type="hidden" name="cartact" value="addtocart" />
  <input type="hidden" name="product_id" id="product_id" value="<?php the_ID(); ?>" />
<?php if(get_option('ptthemes_qty_txt_showhide')=='Hide'){?>
<input name="product_qty" id="product_qty" type="hidden" maxlength="<?php echo get_option('ptthemes_max_qty_decimal');?>" value="1" class="textbox" />
<?php }else{?>
<label class="pfield"> <?php _e('Qty');?> : </label>  <input name="product_qty" id="product_qty" type="text" onkeyup="return isNumberKey(event)" onkeypress="return onlyNumbers(event);"   maxlength="<?php echo get_option('ptthemes_max_qty_decimal');?>" value="1" class="textbox" />
<?php // onkeydown="chkOrder();" 
}?>
<input type="hidden" name="product_att" id="product_att" value="" />
<input type="hidden" name="product_att1" id="product_att1" value="" />
<input type="hidden" name="product_quantity" id="product_quantity" value="1"/>
<input type="hidden" name="product_price" id="product_price" value="<?php echo $product_cart_price;?>" />
<input type="hidden" name="product_istaxable" id="product_istaxable" value="<?php echo $data['istaxable'];?>" />
<input type="hidden" name="product_weight" id="product_weight" value="<?php echo $data[ 'weight']; ?>" />


</div>
<?php
//site_url('/?ptype=cart')
global $General;
$chk_stock = $General->check_stock($post->ID);
if($data['isshowstock']){ $General->display_stock_text($chk_stock);}
if($chk_stock=='out_of_stock'){
if(!$data['isshowstock']){$General->get_out_of_stock_text();}
}else{?>
<div class="addtocart" id="shoppingcart_button_1"><a href="javascript:void(0);" onclick="setAttributeVal();"> <?php _e("Buy now");?> &raquo;  </a></div>
<a href="#addtocartformspan" class="snip" style="display:none;">cart-popup</a>
<span id="shoppingcart_outofstock_msg1" style="display:none;"></span>
<?php }?>
</form>
<span id="addtocartformspan">
<?php if($Cart->is_product_in_cart($post->ID)){echo '<b>'.__(ALREADY_ADDED_CART_MSG).'<Br><a href="'.site_url('/?ptype=cart').'">'.__(VIEW_CART_DETAIL_TEXT).'</a>';}?>
</span>
<script>
function setAttributeVal1()
{
	var subcat = document.getElementById("product_id").value;
	var cat = document.getElementById("cat").value;
	if(cat.search("+") > 0){
		var cat = cat.replace("+","amp");
		}
	
	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp = new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
		if(xmlhttp.responseText != "")
		{
			document.getElementById('addtocartformspan').innerHTML = xmlhttp.responseText;
		}
    }
  }
xmlhttp.open("GET","<?php echo get_template_directory_uri();  ?>/getsubcat.php?q="+subcat+"&cat="+cat,true);
xmlhttp.send();
}
</script>
<script>
function chkOrder()
{
	var pid = document.getElementById("product_id").value;
	var color = "";
	var size = "";
	var attribute3 = "";
	var attribute4 = "";
	var attribute5 = "";
	var attribute6 = "";
	var attribute7 = "";
	var attribute8 = "";
	var attribute9 = "";
	var attribute10 = "";
	
	var qty = document.getElementById("product_quantity").value; 
	if(document.getElementById("color"))
	{
		color = document.getElementById("color").value;
		if(color != ""){
		color = color.replace("+","amp");
		}
	}
	if(document.getElementById("attribute3"))
	{
		attribute3 = document.getElementById("attribute3").value;
		if(attribute3 != ""){
		attribute3 = attribute3.replace("+","amp");
		}
	}
	if(document.getElementById("attribute4"))
	{
		attribute4 = document.getElementById("attribute4").value;
		if(attribute4 != ""){
		attribute4 = attribute4.replace("+","amp");
		}
	}
	if(document.getElementById("attribute5"))
	{
		attribute5 = document.getElementById("attribute5").value;
		if(attribute5 != ""){
		attribute5 = attribute5.replace("+","amp");
		}
	}
	if(document.getElementById("attribute6"))
	{
		attribute4 = document.getElementById("attribute6").value;
		if(attribute6 != ""){
		attribute6 = attribute6.replace("+","amp");
		}
	}
	if(document.getElementById("attribute7"))
	{
		attribute7 = document.getElementById("attribute7").value;
		if(attribute7 != ""){
		attribute7 = attribute7.replace("+","amp");
		}
	}
	if(document.getElementById("attribute8"))
	{
		attribute8 = document.getElementById("attribute8").value;
		if(attribute8 != ""){
		attribute8 = attribute8.replace("+","amp");
		}
	}if(document.getElementById("attribute9"))
	{
		attribute9 = document.getElementById("attribute9").value;
		if(attribute9 != ""){
		attribute9 = attribute9.replace("+","amp");
		}
	}
	if(document.getElementById("attribute10"))
	{
		attribute10 = document.getElementById("attribute10").value;
		if(attribute10 != ""){
		attribute10 = attribute10.replace("+","amp");
		}
	}
	if(document.getElementById("size"))
	{
		size = document.getElementById("size").value;
		if(size!=""){
			 size = size.replace("+","amp");
		}
	}

	if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp = new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange=function()
  {	
  	if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
    {
		if(xmlhttp.responseText != "")
		{
			if(xmlhttp.responseText == "false")
			{
				if(document.getElementById("shoppingcart_button_1"))
				{
					document.getElementById("shoppingcart_button_1").style.display="none";
				} 
				if(document.getElementById("shoppingcart_outofstock_msg1"))
				{
					document.getElementById("shoppingcart_button_1").style.display='none';
					document.getElementById("shoppingcart_outofstock_msg1").style.display='';
					document.getElementById("shoppingcart_outofstock_msg1").innerHTML="this product is out of stock";
					
				}
			}
			else if(xmlhttp.responseText == "true")
			{
				if(document.getElementById("shoppingcart_outofstock_msg1"))
				{
					document.getElementById("shoppingcart_outofstock_msg1").innerHTML="";
					document.getElementById("shoppingcart_button_1").style.display="";
					document.getElementById("shoppingcart_outofstock_msg1").style.display='none';
					
				}
			}
		}
     }
  }

xmlhttp.open("GET","<?php echo get_template_directory_uri();  ?>/chkorder.php?color="+color+"&size="+size+"&pid="+pid+"&qty="+qty+"&attribute3="+attribute3+"&attribute4="+attribute4+"&attribute5="+attribute5+"&attribute6="+attribute6+"&attribute7="+attribute7+"&attribute8="+attribute8+"&attribute9="+attribute9+"&attribute10="+attribute10,true);
xmlhttp.send();
}
</script>